﻿Imports System.Data
Imports AutoDevModel
Imports VSModel
Imports Cls_Common
Imports SecurityService
Partial Class Control_Users_MCCAcc
    Inherits System.Web.UI.UserControl

    Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click

        Using _data As New AutoDevEntities
            Dim p = (From q In _data.Accs Where q.WebsiteID = hidProvinceId.Value Select q).FirstOrDefault
            If Not p Is Nothing Then
                p.AccName = txtUsername.Text
                p.Password = txtPassword.Text
                p.Sport = txtFullname.Text  'for fullname
                _data.SaveChanges()

            End If
        End Using
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Using _data As New VSEntities
            hidID.Value = Request("UserId")
            Dim k = (From q In _data.UsersProvinces Where q.ProvinceId = hidID.Value Select q).FirstOrDefault
            If Not k Is Nothing Then
                hidProvinceId.Value = k.ProvinceId
            End If
        End Using

        Using _data As New AutoDevEntities
            Dim p = (From q In _data.Accs Where q.WebsiteID = hidProvinceId.Value Select q).FirstOrDefault
            If Not p Is Nothing Then
                txtUsername.Text = p.AccName
                txtPassword.Attributes.Add("value", p.Password)
                txtFullname.Text = p.Sport 'for fullname
            End If
        End Using
    End Sub
End Class
